﻿@model Century.Model.CMS.SitePage
@{
    Layout = "~/Areas/Admin/Views/Shared/_TreeLayout.cshtml";
    ViewBag.FormHeaderText = "Add New Page";
    var options = new AjaxOptions()
    {
        Url = Url.Action("SaveNewForm", "PageManagement"),
        UpdateTargetId = "Result",
        OnSuccess = "OnSuccess",
        OnFailure = "OnFailure"
    };  
}
@Html.Partial("_MessageBox")

@{Html.EnableClientValidation();}

@using (Ajax.BeginForm("SaveNewForm", options))
{
    @Html.Partial("Fields")
}

@section scripts{
    <script type="text/javascript">
        $(document).ready(function () {
            $('#PostIT').click(function () {
                $(this).parents('form').submit();
                return false;
            });
        });

        function OnSuccess(data) {
            document.location.href = '@(Url.Action("Get", "PageManagement"))' + '/' + data;
    }

    function OnFailure(data) {
        OpenPopup('Message', 'An error occured during save operation. <br/>Please try again or contact with administrator.', true);
    }
    </script>
}
